/*
 * @Author: LENOVO\zhangch17 zhangch17@Lenovo.com
 * @Date: 2022-11-03 14:21:14
 * @LastEditors: LENOVO\zhangch17 zhangch17@Lenovo.com
 * @LastEditTime: 2022-11-03 14:29:29
 * @FilePath: \mall\src\store\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

import api from '@/assets/config/api.js'
import axios from 'axios'
export default new Vuex.Store({
  state: {
    cartTotal: {
      goodsCount: 0,
      goodsAmount: 0,
      checkedGoodsCount: 0,
      checkedGoodsAmount: 0
    },
    cartList: [],
<<<<<<< HEAD
=======
<<<<<<< HEAD
  },
  mutations: {
=======
>>>>>>> release

  },
  mutations: {
    //啊实打实大苏打
<<<<<<< HEAD
=======
>>>>>>> 7ead64af (提交代码)
>>>>>>> release
    setCarList: function (state, cartList) {
      state.cartList = cartList
    },
    setCartTotal: function (state, cartTotal) {
      state.cartTotal = cartTotal
    }
  },
  actions: {
    AjaxCart: async function (content) {
      let cartRes = await axios.get(api.CartList)
      console.log(cartRes.data)
      content.commit('setCarList', cartRes.data.data.cartList)
      content.commit('setCartTotal', cartRes.data.data.cartTotal)
    }
  },
  modules: {
  }
})
